<!DOCTYPE html>
<html lang="en">
<head>
  
<meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商城详情页视频</title>
  <meta name="viewport" content="initial-scale=1, maximum-scale=1">
  <!-- <link rel="shortcut icon" href="http://favicon.ico"> -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">


  <link rel="stylesheet" href="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/css/sm.min.css">
  <link rel="stylesheet" href="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/css/sm-extend.min.css">
  <script type="text/javascript" src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/common/common/common.js"></script>
  <style type="text/css">

    /*设置默认样式*/
    *{
      margin: 0;
      padding: 0;
    }

   /*修改标题栏颜色*/
    .bar.bar-nav {
      background-color: #1FCA23;
    }

    /*修改标题栏字体颜色*/
    .bar.bar-nav .title {
      color: #fff;
    }
    
    /*修改工具栏背景颜色*/
    .bar.bar-tab {
      background-color: #FEEA4D;
    }
    #pull-left{
      display:inline-block;
      width: 1.5rem;
      padding-top:0.3rem;
      float: left;
    }
    #pull-left img{
      display: block;
      width: 100%;
    }
    #pull-title{
      display: inline-block;
      width: 8.0rem;
      height: 2.2rem;
      line-height: 2.2rem;
      float: left;
      margin-left: 30%;
      color: #fff;
      font-size: 16px;
    }
    /*修改内容区背景色*/
    
    
    /*去掉列表框的线*/
    .list-block ul:before, .list-block ul:after {
      /*background-color: #fff;*/
      display: none;
    }
    
    /*设置列表中li的样式*/
    .list-block .item-content {
/*      padding-right: 0.75rem;
      padding: 0;
      margin: 0 1.5rem;
      border-bottom: 1px dashed #89DAF5;
      z-index: 100;*/
    }

    /*设置列表框中横线*/
    .list-block .item-inner{
      /*border-bottom: 1px dashed #89DAF5;
      z-index: 100;*/
    }

    /*设置列表中显示文字的内边距*/
    /*.list-block .item-media+.item-inner {*/
      /*margin: 0 0.75rem;*/
      /*padding-left: 0.75rem;*/
    /*}*/
    
    .list-block .item-inner:after {
      display: none;
    }
    /*设置page背景色*/
    .page{
      background:#fff;
    }
    /*设置card-footer的底部边框样式*/
/*    #foot_style{
      border-bottom:1px solid #fff;
    }*/

   /*设置card的样式*/
   #card_style{
     width: 100%;
     height:auto;
     margin:0 0 0 0;
   }
    /*设置导航条图标样式*/
    .pull-left{
      padding:0.3rem 0;
    }
    .pull-right{
      padding:0.3rem 0;
    }
    /*设置list-block .item-content样式*/
    #licon{
      padding-left: 0.4rem;
    }

    /*设置图片*/
    .item-media{
      width:45%;
      height:20%;
    }
    .item-media img{
      display: block;
      width:100%;
      height:100%;
    }
    /*视频*/
    .video{
      width: 100%;
      height: 40%;
    }
    .card-content{
      width: 100%;
      padding: 0.5rem 0.2rem 0.8rem 0.6rem;
    }

    /*设置文字样式*/
    .list-block .item-subtitle{
        font-size: 0.8rem;
        white-space: normal;
        margin-top:0.8rem;
    }
    #titlename h4{
      font-size: 16px;
    }
    #titleprice{
       color:#f00b0d;
       font-size: 14px;
       font-weight:bolder;
    }

    /*下载按钮样式*/
    #down{
      display: block;
      width:4.0rem;
      height:2.2rem;
      position: relative;
      margin-left:1.0rem;
    }
   .b_two{
    color:black;
    font-size:0.75rem;
    position: absolute;
    margin-top:0.5rem;
    margin-left:0.2rem;
   }
   /*收藏按钮*/
   #coll{
      width:1.9rem;
      height:1.9rem;
      position: relative;
      margin-right:12%;
   }
   #love{
     display:inline-block;
     position: absolute;
     top:0.1rem;
     left:0.05rem;
     display: none;
   }

   /*设置购买按钮样式*/
    #p_btn{
    width:40%;
    float: left;
    margin-left:30%;
   }

   /*内容简介部分样式*/
  #padd_con{
    clear: both;

  }
  /*底部工具栏部分 */
  #bookfoot{
    width: 100%;
    height: 3.0rem;
    border-top:1px solid #ededee;
    position: fixed;
    bottom:0;
    z-index: 200;
  }
  #foot-left{
    width: 52%;
    height: 3.0rem;
    background-color:#fff;
    float: left;
  }
  #foot-left div{
    width: 21%;
    height: 2.8rem;
    padding-top:0.2rem;
    float: left;
    margin:0 5.5%;
    text-align: center;
  }
   #foot-left div a{
    display: block;
    width: 80%;
    margin:0 auto;
   }
  #foot-left div a img {
    display: block;
    width: 100%;
  }
   #foot-left div span{
    font-size: 14px;
    display: block;
   }
  #foot-btn{
    width: 48%;
    height: 3.0rem;
    line-height: 3.0rem;
    background-color:#1FCA23;
    float: right;
    color: #fff;
    font-size: 16px;
    text-align: center;
  }

  </style>
</head>
<body>
  
  <div class="page-group">
    <div class="page">
      <!-- 标题栏 -->
      <header class="bar bar-nav">
         <a href="#" id="pull-left" onclick="backclick()"><img src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/back@2x.png"></a>
         <span id="pull-title">视频详情页</span>
      </header>
      <!-- 内容部分 -->

      <div class="content">
      <div class="card" id="card_style">
         <iframe onclick="videoplay()" src="https://v.qq.com/iframe/player.html?vid=i0314gnvro5" allowfullscreen="" frameborder="0" class="video"></iframe>
          <div class="card-content" id="titlename">
              <!-- <h4>六年级语文上册（试用版）</h4>
              <div id="titleprice">价格:&nbsp;&nbsp;￥{item.price}元</div> -->
          </div>
          <!-- <div class="card-footer" id="foot_style">
              <span id="down">
                <img src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/down.png" alt="">
                <b class="b_two"></a>0次</b>
              </span>
              <span id="coll">
                  <img id="moz" src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png" state="0" alt="" onclick="loveclick(this)">
              </span>
          </div> -->
      </div>

      <!-- 购买按钮 -->
    <!--    <p id="p_btn">
            <a href="#" class="button button-fill">购买</a>
       </p> -->
       
       <!-- 内容介绍部分 -->    
       <div class="content-padded" id="padd_con">
           <h4>内容简介</h4>
           <div id="desc">
          <!--    <p style="text-indent:2em;">本产品为《义务教育教科书 语文一年级下册》点读资源数据包，专用于
           人教以听点读资源数据包，专用于人教以听点读资源数据包，专用于人教以听点读资源数据包，专用于人教以听。</p> -->
           </div>
           
       </div>

       <!-- 底部工具栏部分 -->
       <div id="bookfoot">
          <div id="foot-left">
             <div>
               <a href="#" onclick="clkcomment()"><img src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/news.png"></a>     
               <span id="commentnum"></span>
             </div>
             <div>
               <a href="#"> <img src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/down.png"></a>              
               <span></span>
             </div>
             <div>
               <a href="#"><img id="moz" src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png" state="0" alt="" onclick="loveclick(this)"></a>       
               <span id="likenum"></span>
             </div>
          </div>
          <div id="foot-btn">
            <span>￥29.90</span>
            <span id="judge">&emsp;</span>
          </div>
       </div>


</div>
                
    </div>
  </div>

  <!-- 固定的js引用，所有的jQuery 要用 $$ 表示 --> 
<script type="text/javascript" src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/js/js/jquery-1.11.1.min.js"></script>
<!-- 这一行代码是为了 避免js冲突 -->
<script type="text/javascript">var $$ =jQuery.noConflict();</script>

<script type='text/javascript' src='https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/zepto/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/js/js/sm.min.js' charset='utf-8'></script>
<!-- <script type='text/javascript' src='https://gitee.com/huaflower/CommonFile/raw/master/js/sm-extend.min.js' charset='utf-8'></script> -->
<script src="https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/js/js/swiper/swiper.min.js"></script>
<script type="text/javascript">

  // 当前商品id
  var curgoods_id = "-1";

  // 点击返回
  function backclick(){
   native_goto('local/finish');
  }

  // 点击视频进入视频播放界面
  function videoplay(){
    native_goto('local/videoplay');
  }

  // 点击评论按钮进入评论界面
  function clkcomment(){
    native_goto('local/comment?cid='+curgoods_id+'&type=1');
  }

 // 遍历数据
  function getData(cid){ 
    var param = {}
    var url = 'api/v1/videos/'+cid;
    net_request('get',url,param,successCallBack,errorCallBack);
 }

 // 判断当前用户是否购买
 function judgeOrder(cid){
   var param = {}
   var url = 'api/v1/videos?search=goods_id:'+curgoods_id+';user_id:'+curuserid+'&searchJoin=and';
   net_request('get',url,param,judgeOrderSuccessCallBack,errorCallBack);
 }

 // 查询该用户是否点赞
 function booklikes(cid){
   var param = {}
   var url = 'api/v1/user_book_likes?search=user_id:'+curuserid+';type:1;goods_id:'+curgoods_id+';islike:1&searchJoin=and';
   net_request('get',url,param,booklikesSuccessCallBack,errorCallBack);
 }

 // 遍历数据 点赞接口
  function getlikes(cid){
   var param = {}
   var url = 'apis/likebook?user_id='+curuserid+'&goods_id='+curgoods_id+'&type=1';
   net_request('get',url,param,getlikesSuccessCallBack,errorCallBack);
  }
  
 // 成功函数回调 判断当前用户是否购买
 function judgeOrderSuccessCallBack(data){

    // 调用查询是否点赞函数
    booklikes(); 

   if (isNotNull(data) && data.success) {
       $$('#judge').html("立即下载");
   }else{
       $$('#judge').html("立即购买");
   }
 }

  // 成功函数回调 查询当前用户是否点赞
  function booklikesSuccessCallBack(data){

     if (isNotNull(data) && data.success) {
        var item = data.data;
        if (isNotNull(item) && item.length > 0) {
           $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love2.png");
        }
        if (!isNotNull(item) || item.length == 0) {
           $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png");
        }
       
     }
  }
   
 // 成功函数回调 用户点赞
  function getlikesSuccessCallBack(data){
      if (isNotNull(data) && data.success) {
        var item = data.data;
        if (isNotNull(item)) {
           var islikeitem = item.islike;
           var num = parseInt($$('#likenum').text());
           // alert(item.islike);
           if (islikeitem == 1) {
              num = num + 1;
              $$('#likenum').text(num);
              $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love2.png");
           }else{
              num = num - 1;
              $$('#likenum').text(num);
              $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png");
           }
        }
    }  
  }
   
 // 成功函数回调  页面
 function successCallBack(data){
   // console.log(JSON.stringify(data));
   // console.log(data);
   // 判断当前用户是否购买
   judgeOrder();

   if (isNotNull(data)) {
     var item = data.data;
     // console.log(JSON.stringify(item));
     // console.log(item);
    // 生成新的HTML
     var html = '';
     var content = '';
     // 遍历数据                 
      if (isNotNull(item)) {

                 if (isNotNull(item.likenum)) {
                     var itemlikenum = item.likenum;
                     $$('#likenum').html(itemlikenum);
                     $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love2.png");
                 }else{
                     $$('#likenum').html("0");
                     $$('#moz').attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png");
                 }
                 if (isNotNull(item.commentnum)) {
                     var itemcommentnum = item.commentnum;
                     $$('#commentnum').html(itemcommentnum);
                 }else{
                     $$('#commentnum').html("0");
                 }


                    html = `
                            <h4>${item.name}</h4> 
                            <div id="titleprice">价格:&nbsp;&nbsp;￥${item.price}元</div>
                           `; 
                    
                    content = `<p style="text-indent:2em;">${item.desc}</p>`;

                    if (!isNotNull(item.desc)) {
                         content = "无";
                     }

                 }

      
                $$('#titlename').html(html);
                $$('#desc').html(content);       
     
   }
 }

 // 失败函数回调
 function errorCallBack(data){
   console.log(JSON.stringify(data));
 }

  function getParams(data){
   // data需要转成json调用 ，函数urlParamParseJson();
     var jodata = urlParamParseJson(data);
     if(isNotNull(jodata)){//

        curgoods_id = jodata.cid;
        getData(jodata.cid);

     }

  }

   // 点击出现收藏或取消收藏事件
   function loveclick(cthis) {

     // 调用 用户点赞函数
     getlikes();

    // var state = Number($$(cthis).attr("state"));
    // if(state == 0){
    //   $$(cthis).attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love2.png");
    //   $$(cthis).attr("state","1");
    // }else{
    //   $$(cthis).attr("src","https://gitee.com/huaflower/ReadBook_CommonFile/raw/master/img/img/love.png");
    //   $$(cthis).attr("state","0");
    // }
   }

    
    // 初始化
    $(function(){
  
      $.init();
    });
  </script>
</body>
</html>